﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Praxis.Entities;

namespace Praxis.Repository
{
    public class ComprobanteDAO: MasterRepository, IComprobanteDAO
    {
        public List<COMPROBANTE> GetAllComprobantes()
        {
            var query = from c in Context.COMPROBANTEs
                        select c;
            return query.ToList();
        }

        public List<COMPROBANTE> GetComprobanteByCriterio(string criterio)
        {
            if (criterio != "" && criterio != null && criterio != string.Empty)
            {
                var query = from c in Context.COMPROBANTEs
                            where c.NumComprobante.ToUpper().Contains(criterio.ToUpper())
                            select c;
                return query.ToList();
            }
            else
            {
                var query1 = from c in Context.COMPROBANTEs
                             select c;
                return query1.ToList();
                
            }
        }

        public void AddComprobante(COMPROBANTE comprobante)
        {
            Context.COMPROBANTEs.Add(comprobante);
            Context.SaveChanges();
        }
    }
}
